package com.jtbd.controller;

import com.jtbd.constants.ResponseCodeEnum;
import com.jtbd.dto.http.UserEmployeeHttpDto;
import com.jtbd.dto.result.ResponseBaseData;
import com.jtbd.service.EmployeeManagementService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/org/employee")
@Tag(name = "机构员工管理接口")
public class EmployeeManagementController {
    @Autowired
    private EmployeeManagementService employeeManagementService;

    @PostMapping("/addOrgEmployee")
    @Operation(summary = "添加机构员工")
    public ResponseBaseData<Long> addEmployee(@RequestBody UserEmployeeHttpDto info) {
        Long employeeId = employeeManagementService.addEmployee(info);
        return ResponseBaseData.success(employeeId);
    }

    @GetMapping("/deleteOrgEmployee")
    @Operation(summary = "删除机构员工")
    public ResponseBaseData<String> deleteEmployee(@RequestParam Long uid) {
        boolean deleted = employeeManagementService.deleteEmployee(uid);
        return deleted ? ResponseBaseData.success("删除成功") : ResponseBaseData.error(ResponseCodeEnum.ERROR);
    }
}
